Merged
Conversation
Add two vector-form geometric computation methods to MathUtils: - perpendicular_foot: projects a point onto a line using dot-product projection, with degenerate segment and non-finite result validation - angle_bisector_direction: computes unit bisector vector by normalizing and summing arm vectors, with zero-length arm and collinear validation
Introduce ConstructionManager following the TangentManager pattern with five geometric constructions: midpoint, perpendicular bisector, perpendicular from point, angle bisector, and parallel line. Constructions produce static Point/Segment snapshots via existing managers. Composite constructions (perpendicular from point) use the suspend_archiving pattern for single-undo-step behavior. Degenerate segments are rejected in the shared slope helper.
Register five construction tools in FunctionRegistry (_build_registry and get_undoable_functions) and add strict JSON schemas in functions_definitions.py: construct_midpoint, construct_perpendicular_ bisector, construct_perpendicular_from_point, construct_angle_bisector, and construct_parallel_line. Update tool discovery test data (count 85, new hash).
Add test_construction_manager.py with 38 tests across 6 classes covering midpoint, perpendicular bisector, perpendicular from point, angle bisector, parallel line, and low-level math utility functions. Tests verify geometric correctness, undo behavior, edge cases, and error handling for degenerate inputs.
Document midpoint, perpendicular bisector, perpendicular from point, angle bisector, and parallel line constructions with example prompts and Canvas/ConstructionManager API reference entries.
When construct_angle_bisector is called with angle_name referencing a reflex angle, negate the bisector direction so it points into the reflex arc instead of the minor arc.
Completed in PR #41. Circle-through-3-points deferred to future work.
Add MathUtils.circumcenter() (determinant-based formula) and MathUtils.incenter_and_inradius() (weighted-average incenter with inradius = 2*area/perimeter). Both reject degenerate inputs. Add ConstructionManager methods: create_circumcircle() supports triangle name or 3 point names, create_incircle() takes a triangle name. Both use suspend_archiving for single-undo-step semantics. Also fix angle bisector vertex attribute (vertex → vertex_point).
Add delegation methods in DrawableManager and Canvas. Register construct_circumcircle and construct_incircle in FunctionRegistry (registry, operation names, undoable list). Add AI tool schemas with strict mode. Update tool discovery metadata (85 → 87 tools).
TestConstructCircumcircle: by triangle name, by 3 point names, collinear raises, no args raises, undo. TestConstructIncircle: right triangle inradius, nonexistent raises, undo. Math utility tests: circumcenter right/equilateral/collinear, incenter equilateral/degenerate.
Add Example Prompts for circumcircle, incircle, and circle-through-3- points. Add Reference Manual entries. Update todo to reflect circumcircle/incircle completion alongside PR #41.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConstructionManagerfollows theTangentManagerpattern — computes geometry, then creates standard Point/Segment drawables via existing managerssuspend_archivingpattern for single-undo-step behaviorNew AI tools
construct_midpoint— midpoint of two points or a segmentconstruct_perpendicular_bisector— perpendicular bisector of a segmentconstruct_perpendicular_from_point— drop perpendicular from point to segmentconstruct_angle_bisector— bisect an angle (by vertex + arm points or angle name)construct_parallel_line— line through a point parallel to a segmentFiles changed
math_utils.py— addedperpendicular_foot()andangle_bisector_direction()construction_manager.py— new manager (5 public methods)drawable_manager.py/canvas.py— wiring and delegationfunction_registry.py— tool registration + undoable listfunctions_definitions.py— 5 AI tool schemastool_discovery_cases.yaml— updated tool count/hashtest_construction_manager.py— 38 Brython tests (6 test classes)Example Prompts.txt/Reference Manual.txt— documentationTest plan